import sys

from PySide2.QtCore import Qt
from PySide2.QtWidgets import (
    QApplication,
    QHBoxLayout,
    QLabel,
    QMainWindow,
    QVBoxLayout,
    QWidget,
    )

from color_widget import ColorWidget

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("Nesting Layout Sample")
        self.setFixedSize(600, 300)

        layout1 = QHBoxLayout()
        layout2 = QVBoxLayout()
        layout3 = QVBoxLayout()        
        
        layout2.addWidget(ColorWidget("red"))
        layout2.addWidget(ColorWidget("yellow"))
        layout2.addWidget(ColorWidget("purple"))
        layout1.addLayout(layout2)        
        layout1.addWidget(ColorWidget("green"))

        layout3.addWidget(ColorWidget("red"))
        layout3.addWidget(ColorWidget("purple"))
        layout1.addLayout(layout3)

        widget = QWidget()
        widget.setLayout(layout1)
        self.setCentralWidget(widget)
        
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()